﻿using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Travel.API.Services;
using AutoMapper;
using Travel.API.Dto;

namespace Travel.API.Controllers
{
    [Route("api/TouristRoute/{TouristRouteId}/photo")]
    public class TouristRoutePhotoController : ControllerBase
    {
        private readonly ITouristRouteServices _touristRouteServices;
        private readonly IMapper _mapper;
        public TouristRoutePhotoController(ITouristRouteServices touristRouteServices, IMapper mapper)
        {
            this._touristRouteServices = touristRouteServices;
            _mapper = mapper;
        }
        [HttpGet]
        public IActionResult GetTouristRoutePhotoById(Guid TouristRouteId)
        {
            if (!_touristRouteServices.TouristRoutesExistence(TouristRouteId))
            {
                return NotFound("不存在该资源路线404");
            }
            var data = _touristRouteServices.GetTouristRoutesIdByPhoto(TouristRouteId).ToList();

            if(data==null||data.Count()<=0)
            {
                return NotFound("照片不存在");
            }

            var datadto = _mapper.Map<IEnumerable<TouristRoutePhotoDto>>(data);
            return Ok(datadto);
        }




    }
}
